# queue
from collections import deque

# 入队和出队 append 和 popleft
# 右边进
q = deque()
q.append(1)
q.append(2)
q.append(3)
# 出队 左边出
print(q.popleft())  # 1
print(q.popleft())  # 2
print(q.popleft())  # 3

# 栈 append 和 pop
# range入队 0 1 2 3 4
q = deque(range(5))
q.append(5)

# 右边出队
while len(q) > 0:
    print(q.pop(), end=',')  # 5,4,3,2,1,0,
